<template>
  <div v-cloak id="app">
    <router-view/>
  </div>
</template>

<script>
  import { $config } from 'vue-element-simple';
  export default {
  name: 'App',
  created() {
    const url = 'common/getTitle';
    this.$store.dispatch('GetConnect', { url }).then(res => {
      $config.setConfig({
        // 运行环境
        ENV: res.data.env || 'LOCAL'
      })
      window.document.title = res.data.seo_title || '';
      const link = document.querySelector("link[rel*='icon']") || document.createElement('link');
      link.type = 'image/x-icon';
      link.rel = 'shortcut icon';
      link.href = res.data.seo_ico
      document.getElementsByTagName('head')[0].appendChild(link);
      this.$store.dispatch('SetSiteInfo', {
        seoTitle: res.data.seo_title || '云运维管理系统 | 网商云',
        title: res.data.title,
        needAvatar: res.data.avatar_status,
        pluginOpenType: res.data.pluginOpenType || 0
      })
    }).catch(e => {
      this.$message.error(e.msg + ',请刷新或联系管理员');
    })
  }
}
</script>
